package com.example.aigc_education.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class GetBeanUtil {
    //将管理上下文的applicationContext设置成静态变量，供全局调用
    public static ApplicationContext text;
    //定义一个获取已经实例化bean的方法
    public static <T> T getBean(Class<T> c){
        return text.getBean(c);
    }

    @Resource
    public void setApplicationContext(ApplicationContext applicationContext) {
        text = applicationContext;
    }
}
